//
//  MineViewController.swift
//  SwiftProject
//
//  Created by qindong on 2021/3/11.
//

import UIKit

class MineViewController: BaseViewController, ListAdapterDataSource {
    lazy var adapter : ListAdapter = {
        ListAdapter(updater: ListAdapterUpdater(), viewController: self)
    }()
    let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
    var data : [BaseIGListKitModel] = [FQMineHeaderModel(), FQMineAdModel(), FQMineServiceModel()]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBarType = .clear
        // Do any additional setup after loading the view.
    }
    
    override func initSubviews() {
        super.initSubviews()
        
        collectionView.contentInsetAdjustmentBehavior = .never
        collectionView.backgroundColor = .qmui_color(withHexString: "ecf2fc")
        collectionView.alwaysBounceVertical = true
        view.addSubview(collectionView)
        
        collectionView.snp.makeConstraints { make in
            make.top.left.right.equalTo(view)
            make.bottom.equalTo(-TabBarHeight)
        }
        
        adapter.collectionView = collectionView
        adapter.dataSource = self
    }
    
    func objects(for listAdapter: ListAdapter) -> [ListDiffable] {
        data
    }
    
    func listAdapter(_ listAdapter: ListAdapter, sectionControllerFor object: Any) -> ListSectionController {
        switch object {
        case is FQMineServiceModel:
            return FQMineServiceSectionController()
        case is FQMineAdModel:
            return FQMineAdController()
        default:
            return FQMineHeaderSectionController()
        }
    }
    
    func emptyView(for listAdapter: ListAdapter) -> UIView? {
        nil
    }
    
    override func setupNavigationItems() {
        super.setupNavigationItems()
    }
    
    override func customNavigationBarTransitionKey() -> String? {
        "mine"
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        .default
    }
}
